package file_manage

import (
	"game-time-management/types"
	"os"
	"strconv"
	"strings"
	"time"
)

func Read() [2]int64 {
	t, err := os.ReadFile(types.Filepath)
	now := time.Now().Unix()
	if err != nil {
		return [2]int64{now, now}
	}
	r := strings.Split(string(t), " ")
	switch len(r) {
	case 0:
		return [2]int64{now, now}
	default:
		t1, err := strconv.ParseInt(r[0], 10, 64)
		if err != nil {
			t1 = now
		}
		t2, err := strconv.ParseInt(r[1], 10, 64)
		if err != nil {
			t2 = now
		}
		return [2]int64{t1, t2}
	}
}
